package com.design.pattern.state.base;

import lombok.Getter;

/**
 * @author 王霄
 * @date 2022/3/10 20:35
 */
public class Context {

    @Getter
    private CarState currentState;
    private final Car car;

    public Context(CarState currentState) {
        this.currentState = currentState;
        this.currentState.context = this;
        this.car = new Car(currentState.getState());
    }

    public void setCurrentState(CarState currentState) {
        this.currentState = currentState;
        this.currentState.context = this;
        this.car.setCatState(currentState.getState());
    }
}
